package a1_graph_lib;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class Vertex {

	// Vertex_ID
	private int vertex_id;
	private String name; // Name auch als attribut?

	private final String EMPTY_STRING = "";

	// Attribute
	private Map<String, Attribut> attrMap = new HashMap<String, Attribut>();

	// Constructor
	Vertex(int vertex_id, String name) {
		this.vertex_id = vertex_id;
		this.name = name;
	}

	public int getID() {
		return vertex_id;
	}

	public String getName() {
		return name;
	}

	public int getVal(String attr) {
		if (!attrMap.containsKey(attr)) {
			return Integer.MAX_VALUE;
		}
		return attrMap.get(attr).getVal();
	}

	public String getStr(String attr) {
		if (!attrMap.containsKey(attr)) {
			return EMPTY_STRING;
		}
		return attrMap.get(attr).getStr();
	}

	public ArrayList<String> getAttr() {
		ArrayList<String> attr_list = new ArrayList<String>(attrMap.keySet());
		return attr_list;
	}

	public boolean setVal(String attr, int val) {
		AttributNumber newAttr = new AttributNumber(attr, val);
		attrMap.put(attr, newAttr);
		return true;
	}

	public boolean setStr(String attr, String val) {
		AttributString newAttr = new AttributString(attr, val);
		attrMap.put(attr, newAttr);
		return true;
	}

}